local thbattle__tuanzang_bianhua = fk.CreateSkill {

  name = "thbattle__tuanzang_bianhua",

  tags = {},

}



thbattle__tuanzang_bianhua:addEffect("viewas", {
  prompt = "#thbattle__tuanzang_bianhua",
  anim_type = "special",
  pattern = ".",
  interaction = function(self, player)
    local all_names = THB_Utility.getAllCardNames("bt")
    local names = {}
    for _, name in ipairs(all_names) do
      local card = Fk:cloneCard(name)
      if not card.is_derived and Fk.currentResponsePattern == nil and card.skill:canUse(player, card) and card.is_passive~=true
        and player:canUse(card) then
        table.insertIfNeed(names, card.name)
      end
    end
    if #names == 0 then return end
    return UI.ComboBox { choices = names }
  end,
  card_num = 2,
  card_filter = function(self, player, to_select, selected)
    if Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand then
      if #selected == 0 then
        return true
      elseif #selected == 1 then
        local selected_1 = Fk:getCardById(selected[1])
        local interaction_card = Fk:cloneCard(self.interaction.data)
        if selected_1.type == interaction_card.type then
          return true
        else
          return Fk:getCardById(to_select).type == interaction_card.type
        end
      else
        return false
      end
    end
  end,
  view_as = function(self, player, cards)
    if not self.interaction.data then return end
    if #cards ~= 2 then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcards(cards)
    card.skillName = thbattle__tuanzang_bianhua.name
    return card
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(thbattle__tuanzang_bianhua.name, Player.HistoryPhase) == 0 and
        #player:getCardIds("h") > 1 and player.phase==Player.Play
  end,
  enabled_at_response = function(self, player, response)
    return false
  end
})

return thbattle__tuanzang_bianhua
